package com.itheima.controller;


import com.github.pagehelper.PageInfo;
import com.itheima.bean.Student;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import javax.servlet.http.HttpServlet;


//@Controller
//@ResponseBody
@RestController
@RequestMapping("/student")
public class StudentController extends HttpServlet {

    @Autowired
    private StudentService studentService;




    @GetMapping("{currentPage}/{pageSize}")
    protected PageInfo<Student>  selectByPage(@PathVariable Integer currentPage,@PathVariable Integer pageSize){
        return  studentService.selectByPage(currentPage, pageSize);
    }

    @PostMapping
    protected Integer addStudent(@RequestBody Student student){
       return studentService.addStudent(student);
    }

    @PutMapping
    protected Integer updateStudent(@RequestBody Student student){
        return studentService.updateStudent(student);

    }

    @DeleteMapping("{number}")
    protected Integer deleteStudent(@PathVariable String number) {
       return studentService.deleteStudent(number);

    }


}
